﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;


namespace TMTemplate
{
	public partial class Menu : UserControl
	{
		DispatcherTimer timer = new DispatcherTimer();
		public Menu()
		{
			InitializeComponent();
            VisualStateManager.GoToState(this, "Close", false);
            timer.Interval = new TimeSpan(0, 0, 0, 1);
            this.MouseEnter += new MouseEventHandler((s, e) => { VisualStateManager.GoToState(this, "Open", false); timer.Stop(); });
            this.MouseLeave+=new MouseEventHandler(Menu_MouseLeave);
		}

        void Menu_MouseLeave(object sender, MouseEventArgs e)
        {
            timer.Start();
            timer.Tick += new EventHandler((_s, _e) =>
            {
                VisualStateManager.GoToState(this, "Close", false);
                timer.Stop();
            });
        }
    }
}